# -*- coding: utf-8 -*-
import random
from time import *

def create_phone():
    # 第二位数字
    second = [3, 5, 7, 8][random.randint(0, 3)]

    # 第三位数字
    third = {
        3: random.randint(0, 9),
        4: [5, 7, 9][random.randint(0, 2)],
        5: [i for i in range(10) if i != 4][random.randint(0, 8)],
        7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)],
        8: random.randint(0, 9),
    }[second]

    # 最后八位数字
    suffix = random.randint(9999999,100000000)

    # 拼接手机号
    return "1{}{}{}".format(second, third, suffix)





def make_random_time():
    #mktime(tuple)讲时间元组转换为本地时间
    #日期元组说明：年，月，日，时，分，秒，周，儒历日，夏令时
    date1 = (2017,12,15,0,0,0,-1,-1,-1)
    time1 = mktime(date1)
    date2 = (2019,2,1,0,0,0,-1,-1,-1)
    time2 = mktime(date2)
    #在这一范围内生成随机数
    random_time = random.uniform(time1,time2)#uniform返回随机实数 time1 <= time < time2
    #localtime(seconds)将秒数转换为日期元组
    #asctime([tuple]) 将时间元组转换为字符串
    strftime("%Y-%m-%d %H:%M:%S", localtime(random_time))
    return strftime("%Y-%m-%d %H:%M:%S", localtime(random_time)) + '.' + str(random.randint(0,999999))
